import React, { Component } from 'react'
// import qs from 'querystring-es3'

const DetailData = [
  {
    id: '01',
    content: 'message001 content'
  },
  {
    id: '02',
    content: 'message002 content'
  },
  {
    id: '03',
    content: 'message003 content'
  }
]
export default class Detail extends Component {
  render () {
    console.log(this.props)

    // 接收 params 参数
    // const { id, title } = this.props.match.params

    // 接收search 参数
    //   console.log(this.props)
    //  const {id,title}= qs.parse(this.props.location.search.slice(1))

    // 接收 state 参数
    const { id, title } = this.props.location.state || {}
    const findResult = DetailData.find(detailObj => detailObj.id === id) || {}
    return (
      <ul>
        <li>id:{id}</li>
        <li>tltle:{title}</li>
        <li>content:{findResult.content}</li>
      </ul>
    )
  }
}
